define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'xeditor'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        user_wallet_balance_refund: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'merchant/user_wallet/user_wallet_balance_refund',
                    multi_url: 'merchant/user_wallet/multi',
                    table: 'user_wallet_balance_refund',
                }
            });

            var table = $("#table");

            table.on('click', '.approve', function(re) {
                let id = $(this).data('id');
                Fast.api.open('merchant/user_wallet/user_wallet_balance_refund_approve?id=' + id, '操作', {
                    area: ['380px', '300px']
                });
            });
            table.on('click', '.refuse', function(re) {
                let id = $(this).data('id');
                Fast.api.open('merchant/user_wallet/user_wallet_balance_refund_refuse?id=' + id, '操作', {
                    area: ['560px', '520px']
                });
            });

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'), sortable: true},
                        {field: 'uid', title: '用户ID'},
                        {field: 'oid', title: '订单ID'},
                        {field: 'out_trade_no', title: '充值单号'},
                        {field: 'money', title: '充值金额'},
                        {field: 'balance', title: '实得余额'},
                        {field: 'refund_out_trade_no', title: '退款单号'},
                        {field: 'status', title: '状态', searchList: window.statusListJson, formatter: function(value, row, index) {
                            return row.status_text;
                        }},
                        {field: 'createtime', title: '创建时间', events: Table.api.formatter.datetime,operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {field: 'updatetime', title: '更新时间', events: Table.api.formatter.updatetime,operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {field: '', title: '操作', formatter: function(value, data, index) {
                            if(data.status == 0) {
                                return '<button id="approve" class="btn btn-info approve" data-id="' + data.id + '">通过</button>' + '&nbsp;&nbsp;' + '<button id="refuse" class="btn btn-info refuse" data-id="' + data.id + '">拒绝</button>';
                            }
                        }}
                    ]
                ]
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});